import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { KnowledgeVO, KnowledgeForm, KnowledgeQuery } from '@/api/cemetery/knowledge/types';

/**
 * 查询知识科普列表
 * @param query
 * @returns {*}
 */

export const listKnowledge = (query?: KnowledgeQuery): AxiosPromise<KnowledgeVO[]> => {
  return request({
    url: '/cemetery/knowledge/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询知识科普详细
 * @param id
 */
export const getKnowledge = (id: string | number): AxiosPromise<KnowledgeVO> => {
  return request({
    url: '/cemetery/knowledge/' + id,
    method: 'get'
  });
};

/**
 * 新增知识科普
 * @param data
 */
export const addKnowledge = (data: KnowledgeForm) => {
  return request({
    url: '/cemetery/knowledge',
    method: 'post',
    data: data
  });
};

/**
 * 修改知识科普
 * @param data
 */
export const updateKnowledge = (data: KnowledgeForm) => {
  return request({
    url: '/cemetery/knowledge',
    method: 'put',
    data: data
  });
};

/**
 * 删除知识科普
 * @param id
 */
export const delKnowledge = (id: string | number | Array<string | number>) => {
  return request({
    url: '/cemetery/knowledge/' + id,
    method: 'delete'
  });
};
